﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Category.aspx.cs" Inherits="ZLCMS.Web.Wap.Shop.Category"  MasterPageFile="~/Wap/Shop/ShopSite.Master"%>
<%@ Register src="Footer.ascx" tagname="Footer" tagprefix="uc1" %>
<%@ Register src="UC_ShopNavBar.ascx" tagname="UC_ShopNavBar" tagprefix="uc2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>商品目录</title>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="pages" runat="server">
    <!--S page -->
<div data-role="page" id="mypage">

	<!--S header -->
	<div data-role="header" data-position="fixed" data-tap-toggle="false">
	        <uc2:UC_ShopNavBar ID="UC_ShopNavBar1" runat="server" />
	</div>
    <!--E header -->
	
    <!--S content -->
	<div role="main" class="ui-content">
    <div class="categoryData"></div>
       
 	</div>
    <!--E content -->
	
    <!--S footer -->
	<div data-role="footer" data-position="fixed" data-tap-toggle="false">
                <uc1:Footer ID="Footer1" runat="server"  MenuId="C" />    
    </div>
    <!--E footer -->
</div>
<!--E page -->
    <script src="/wap/lib/common/listviewHandler.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(function () {
            //只支持处理二级分类
            var root = 149;

            var itemTemplate = '<div class="cate_textpic">' +
                                '<div class="LIST">' +
                                    '<div class="left">' +
                                        '<img src="{ImgUrl}">' +
                                    '</div>' +
                                    '<div class="right">' +
                                        '<span>' +
                                           ' <h2>{CategoryName}</h2>' +
                                            '<p>{CategoryDesc}</p>' +
                                        '</span>' +
                                        '<image class="icon" src="images/bottom_icon.png"/>' +
                                    '</div>  ' +
                                '</div>' +
                                '<div class="cate_textbox" style="display:none;">' +
                                    '<a data-ajax="false" href="productlist.aspx?categoryid={Id}">全部</a>{list}' +
                                '</div>' +
                            '</div>';
            $('.categoryData').executeCommand({ successCallBack: function (result) {
                $(result.List).each(function () {
                    var parent = this;
                    //处理1级分类
                    parent.ImgUrl = firstFilePath(parent.ImgUrl);
                    if (parent.ParentId == root) {

                        parent.list = '';
                        //处理2级分类
                        $(result.List).each(function () {
                            if (this.ParentId == parent.Id) {
                                parent.list += '<a data-ajax="false" href="productlist.aspx?categoryid={Id}">{CategoryName}</a>'.format(this);
                            }
                        });


                        $('.categoryData').append(itemTemplate.format(parent));
                    }
                });

                //展开收缩
                $(".cate_textpic .LIST").click(function () {
                    var par = $(this).parents(".cate_textpic"),
				obj = par.find(".cate_textbox"),
				icon = $(this).find(".right").find(".icon");

                    if (obj.css("display") == "none") {
                        icon.attr("src", "images/top_icon.png");
                        obj.slideDown();
                    } else {
                        icon.attr("src", "images/bottom_icon.png");
                        obj.slideUp();
                    }
                });
            }
            }, 'Pub.LoadCategory', { Root: root });
        })

    </script>
</asp:Content>